﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SIAD.Model
{
    /// <summary>
    /// Représenete la façon de jouer au jeu SIAD
    /// </summary>
    class SIADGame : Game
    {
        public SIADGame(Player playerOne, Player playerTwo) : base()
        {            
            PlayerList.Add(playerOne);
            PlayerList.Add(playerTwo);
        }

        public override void initializeGame()
        {
            PlayerList[0].PlacePlayer();
            PlayerList[1].PlacePlayer();
        }

        public override void makePlay(Player player)
        {
            player.MovePlayer();
            player.DropBlock();
        }

        public override bool endOfGame()
        {
            return !PlayerList[0].canMove() || !PlayerList[1].canMove();
        }

        public override void printWinner()
        {
            
            if (!PlayerList[0].canMove() && !PlayerList[1].canMove())
            {
                // Les deux ont perdu
                PlayerList[0].sendMessage("Both player lost !!");
            }
            else if (!PlayerList[0].canMove())
            {
                PlayerList[0].sendMessage("Player 2 win !!");
            }
            else if (!PlayerList[1].canMove())
            {
                PlayerList[1].sendMessage("Player 1 win !!");
            }
            else
            {
                throw new Exception();
            }
        }
    }
}
